part of '../../repository.dart';

class _GooglePlayPurchasedItemDtoFactory {
  const _GooglePlayPurchasedItemDtoFactory._internal();

  static const _instance = _GooglePlayPurchasedItemDtoFactory._internal();

  factory _GooglePlayPurchasedItemDtoFactory() {
    return _instance;
  }

  _GooglePlayPurchasedItemDto fromJson(Map<String, dynamic> json) {
    final type = json[_kGooglePlayPurchasedItemTypeKey];

    switch (type) {
      case _kGooglePlayPurchasedSubscriptionTypeValue:
        return _GooglePlayPurchasedSubscriptionDto.fromJson(json);
      case _kGooglePlayOneTimePurchasedItemTypeValue:
        return _GooglePlayOneTimePurchasedItemDto.fromJson(json);
      default:
        throw UnimplementedError();
    }
  }
}
